package com.uff.hmstpa.model.service.impl;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import com.uff.hmstpa.model.domain.Healthplan;
import com.uff.hmstpa.model.domain.Specialty;
import com.uff.hmstpa.model.mediator.ModelMediator;
import com.uff.hmstpa.model.persistence.impl.CoverageDAOImpl;
import com.uff.hmstpa.model.service.CoverageService;

public class CoverageServiceImpl implements CoverageService {
	
	private Map<Integer, Set<Integer>> coverage = new HashMap<Integer, Set<Integer>>();
	private ModelMediator mediator;
	
	public CoverageServiceImpl() {
		this.coverage = CoverageDAOImpl.getInstance().load();
	}
	
	public boolean isCoveredByPlan(Specialty specialty, Healthplan healthplan) {
		if(coverage.get(healthplan.getCode()).contains(specialty.getCode())) {
			return true;
		} else {
			return false;
		}
	}
	
	public void setMediator(ModelMediator mediator) {
		this.mediator = mediator;
	}
	
	public ModelMediator getMediator() {
		return mediator;
	}

}
